[assembly: WebActivator.PreApplicationStartMethod(typeof(Samples.Web.Template.App_Start.TemplateConfig), "Start")]

namespace Samples.Web.Template.App_Start
{
    using System;
    using System.Linq;
    using System.Net;
    using System.Reflection;
    using System.Web;
    using System.Web.Hosting;

    using Microsoft.Web.Infrastructure.DynamicModuleHelper;

    using VirtualTemplates;
    using System.Web.Optimization;

    public static class TemplateConfig
    {
        public static void Start() 
        {
            HostingEnvironment.RegisterVirtualPathProvider(new VirtualTemplateProvider(new AssemblyVirtualTemplate(Assembly.GetExecutingAssembly(), "Template")));

            DynamicModuleUtility.RegisterModule(typeof(HandleVirtualFileModule));
            
            HandleVirtualFileModule.FileExtensions.Add(".css");
            HandleVirtualFileModule.FileExtensions.Add(".js");

            //BundleTable.VirtualPathProvider = HostingEnvironment.VirtualPathProvider;

            BundleTable.EnableOptimizations = true;

            BundleTable.Bundles.Add(new DynamicFolderBundle("css", "*.css", true));
            BundleTable.Bundles.Add(new DynamicFolderBundle("js", "*.js", true));
        }
    }
}
